﻿package mortal.game.view.flowerSend.panel
{
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.game.view.flowerSend.*;
    import mortal.game.view.flowerSend.data.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class FlowerSendBaseWin extends Window
    {
        private var _bgContentSp:GSprite;
        private var _data:FlowerSendData;
        private var _bg:GImageBitmap;
        private var _currentBox:GSprite;
        public static var sending:int = 1;
        public static var sendSuccess:int = 2;

        public function FlowerSendBaseWin(param1:ILayer = null)
        {
            this.layer = LayerManager.windowLayer;
            this.setSize(433, 450);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bgContentSp = UICompomentPool.getUICompoment(GSprite);
            this._bgContentSp.mouseEnabled = true;
            this.addChild(this._bgContentSp);
            this._bg = UIFactory.gImageBitmap("", 0, -20, this._bgContentSp);
            this._bgContentSp.configEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bgContentSp.dispose(param1);
            this._bgContentSp = null;
            this._bg.dispose(param1);
            this._bg = null;
            this._currentBox.dispose(param1);
            this._currentBox = null;
            this._data = null;
            return;
        }// end function

        public function set data(param1:FlowerSendData) : void
        {
            this._data = param1;
            this._bg.imgUrl = "FlowerSendBg_" + this._data.itemData.itemInfo.type;
            return;
        }// end function

        public function set currentState(param1:int) : void
        {
            if (this._currentBox)
            {
                this._currentBox.dispose(true);
                this._currentBox = null;
            }
            if (param1 == sending)
            {
                this._currentBox = this.addSendSprite();
            }
            else if (param1 == sendSuccess)
            {
                this._currentBox = this.addSendSuccessSprite();
            }
            this.addChild(this._currentBox);
            return;
        }// end function

        private function addSendSprite() : FlowerSendingBox
        {
            var _loc_1:FlowerSendingBox = null;
            _loc_1 = UICompomentPool.getUICompoment(FlowerSendingBox);
            _loc_1.x = 100;
            _loc_1.y = 105;
            _loc_1.data = this._data;
            return _loc_1;
        }// end function

        private function addSendSuccessSprite() : FlowerSendSuccessBox
        {
            var _loc_1:FlowerSendSuccessBox = null;
            _loc_1 = UICompomentPool.getUICompoment(FlowerSendSuccessBox);
            _loc_1.x = 100;
            _loc_1.y = 105;
            _loc_1.data = this._data;
            return _loc_1;
        }// end function

        override public function hide() : void
        {
            super.hide();
            Dispatcher.dispatchEvent(new DataEvent(EventName.FlowerCloseWin));
            return;
        }// end function

        override protected function updateBtnSize() : void
        {
            if (_closeBtn)
            {
                _closeBtn.x = this.width - _closeBtn.width - 75;
                _closeBtn.y = 20;
            }
            return;
        }// end function

    }
}
